<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta content="telephone=no" name="format-detection" />
	<meta name="Description" content=""/>
	<meta name="Keywords" content=""/>
	<link href="favicon.ico" mce_href="favicon.ico" rel="bookmark" type="image/x-icon" />
	<link href="favicon.ico" mce_href="favicon.ico" rel="icon" type="image/x-icon" />
	<link href="favicon.ico" mce_href="favicon.ico" rel="shortcut icon" type="image/x-icon" />
	<title>盖网魔盒</title>
	<link rel="stylesheet" href="css/reset.css">
	<link rel="stylesheet" href="css/styles.css">	
	<script src="js/jquery-2.2.2.min.js"></script>
	<script src="js/cookie.js"></script>
	<script src="js/jquery.flexslider-min.js"></script>
	<script src="js/cryptico.js"></script>
	<script src="js/jsencrypt.js"></script>
	<script src="js/common.js"></script>
	<script>
		$(function(){
			if(window.name=="gwmhLogined"){
				$("#authentication").attr("href","hasLogined.html");
			}

			$(".tooltip-box .close").click(function(){
				$(this).parent().parent().hide();
			})
		})
	</script>	
</head>
<body>
	<header class="header">
		<a href="javascript:history.go(-1)" class="reback"></a>
	</header>
	<section class="container">
		<div class="ca-wrap">
			<div class="logo"></div>
			<div id="login-form">
				<div class="form-row">
					<input type="text" name="user" class="form-input" placeholder="GW号/手机号" required>
				</div>
				<div class="form-row">
					<input type="password" name="psw" class="form-input" placeholder="密码" required>
					<!--<a href="resetPassword.html" class="to-pw-forgot">忘记密码</a>-->
				</div>
				<div class="operation">
					<input type="submit" class="submit-btn" value="登 录" onclick="ajaxlogin()">
					<div class="no-account">
						<p>未有账号？</p>
						<a href="register.html" class="fast-register-btn">快速注册</a>
					</div>
				</div>
			</div>			
			<!--错误弹窗提示-->
			<div class="mask hide">
				<div class="tooltip-box">
					<i class="close"></i>
					<p>密码有误，请重新输入！</p>
				</div>
			</div>			
		</div>
	</section>
	<footer class="footer">
		<ul class="menu clearfix">
			<li>
				<a href="index.html" id="authentication">
					<i class="icon ico-01"></i>
					<span>主页</span>
				</a>
			</li>
			<li>
				<a href="login.html">
					<i class="icon ico-02 active"></i>
					<span>认证上网</span>
				</a>
			</li>
			<li>
				<a href="social.html">
					<i class="icon ico-03"></i>
					<span>局域社交</span>
				</a>
			</li>
		</ul>
	</footer>
	<script>		
		function ajaxlogin(){			
			$(".submit-btn").val("正在登录…");
			var userName =$("input[name=user]").val();
			var Pwd      =$("input[name=psw]").val();

		  //调用卡拉威视外网访问接口
			var encrypt = new JSEncrypt();
			var PublicKeyString = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDFdcf9rnBI5wKkCpJ8yaRviqbXH9cNK/n0foh0s8VLuv+JEvjMESKbE5gYj4FGuIGeEtmTpcchHcI7Z8MTibHHI78CNvy0WsSDyIDMPm+ts/xaeOsiqqAYBYTweGyVrMWKOg6CR0xg4SbtIJ9OGIroclHBjcHZTjsLGm4UHkVsbwIDAQAB";
			encrypt.setPublicKey(PublicKeyString);
			var strGWnumber = encrypt.encrypt(userName);
			var strHexGWnumber = cryptico.b64to16(strGWnumber);
			var strPwd = encrypt.encrypt(Pwd);
			var strHexPwd = cryptico.b64to16(strPwd);
			var strMacCode = "P6AWKC0c9yHnYAnT3Jt22GrtN5u5FS55t7G1803O";
			var strVer = "1";
			$.ajax({
				url: 'http://113.107.148.182:9080/token/login/',
				type: 'post',
				data: {
					"MacCode": strMacCode,
					"GWnumber":strHexGWnumber,
					"pwd":strHexPwd,
					"ver":strVer
				},
				contentType: 'application/x-www-form-urlencoded',
				success: function(re) {					
					var jsonobj=eval('('+re+')');					
					if (jsonobj.Response.resultCode == 1) {
						$.cookie("GWNumber",jsonobj.Response.resultData.gaiNumber);
						window.location.href = "loginSuccess.html";
						//openInternet();						
						//alert("认证成功!");		
						//window.location.href = "http://www.g-emall.com/";						
					}
					else {
						//alert(jsonobj.Response.resultDesc);
						//window.location.href = "./error1.html";
						$('.ca-wrap').append('<div class="mask"><div class="tooltip-box"><i class="close"></i><p>'+jsonobj.Response.resultDesc+'</p></div></div>');
						$(".submit-btn").val("登录");
					  	$(".tooltip-box .close").click(function(){
							$(this).parent().parent().hide();
						})
					}
				},
				complete: function(XHR) {
					if (XHR.status != 200) {
						//alert("用户名或密码不正确");
						//window.location.href = "./error1.html";
						$('.ca-wrap').append('<div class="mask"><div class="tooltip-box"><i class="close"></i><p>'+jsonobj.Response.resultDesc+'</p></div></div>');
						$(".submit-btn").val("登录");
					  	$(".tooltip-box .close").click(function(){
							$(this).parent().parent().hide();
						})
					}
				}
			});
		}		
	</script>
</body>
</html>